import 'package:flutter/material.dart';

class ListViewBuilder extends StatelessWidget {


  List <String> list = [];
  ListViewBuilder({Key ? key}) : super(key : key){
    for(var i = 0; i< 20 ;i++)
    {
      list.add("这是第${i+1}条数据");
    }
  }


  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            leading: IconButton(
              onPressed: (){},
              icon: const Icon(Icons.ac_unit,color: Colors.cyanAccent,),
            ),
          ),
          body: ListView.builder(   //类比于循环，itemCount
              itemCount: list.length,
              itemBuilder: (context , index){
                return ListTile(
                  title: Text("${list[index]}"),
                );

              } )
      ),

    );
  }

}